package com.wc.alorithm_blue_bridge_history.fourteen.互质数的个数;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2024/1/15 20:06
 * @description 互质数的个数
 * ola函数，
 * https://www.lanqiao.cn/problems/3522/learning/?page=1&first_category_id=1
 */
public class Main {
    static int mod = 998244353;
    static long a, b;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        a = sc.nextLong();
        b = sc.nextLong();
        if (a == 1) {
            System.out.println(0);
            return;
        }
        long ans = a;
        long t = a;
        for (int i = 2; (long) i * i <= t; i++) {
            if (t % i == 0) {
                ans = ans * (i - 1) / i % mod;
                while (t % i == 0) {
                    t /= i;
                }
            }
        }
        // 剩下的一个数如果大于1，那么他也是质因子
        if (t > 1) {
            ans = ans * (t - 1) / t % mod;
        }

        System.out.println(pow(a, b - 1) * ans % mod);
    }


    // 快速幂
    static long pow(long a, long b) {
        long res = 1;
        while (b > 0) {
            if ((b & 1) == 1) {
                res = res * a % mod;
            }
            a = a * a % mod;
            b >>= 1;
        }
        return res;
    }
}
